package top.bbman.boot.ali.model;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 祥霸
 * @version 1.0
 */
@Data
public class PeaOssPolicy {

    @JSONField(name = "Version")
    private String version = "1";

    @JSONField(name = "Statement")
    private List<Statement> statement;

    @Data
    public static class Statement {

        @JSONField(name = "Action")
        private List<String> action;

        @JSONField(name = "Resource")
        private List<String> resource;

        @JSONField(name = "Effect")
        private String effect = "Allow";
    }

    public static void main(String[] args) {
        PeaOssPolicy policy = new PeaOssPolicy();
        policy.setVersion("1");

        List<Statement> statementList = new ArrayList<>();
        Statement statement = new Statement();
        statementList.add(statement);
        policy.setStatement(statementList);

        List<String> action = new ArrayList<>();
        action.add("oss:PutObject");
        statement.setAction(action);

        List<String> resources = new ArrayList<>();
        resources.add("acs:oss:*:*:acree/zeus-space/*");
        statement.setResource(resources);

        System.out.println(JSON.toJSONString(policy));
    }
}
